import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-04
 * Time: 14:26
 */
public class Test18 {
    public static void setZeroes(int[][] matrix) {
        int m = matrix.length, n = matrix[0].length;
        boolean[] row = new boolean[m];
        boolean[] col = new boolean[n];

        for(int i = 0; i < m; i++) {
            for(int j = 0; j < n; j++) {
                if(matrix[i][j] == 0) {
                    row[i] = true;
                    col[j] = true;
                }
            }
        }

        for(int i = 0; i < m; i++) {
            for(int j = 0; j < n; j++) {
                if(row[i] || row[j]) {
                    matrix[i][j] = 0;
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[][] num = new int[m][n];
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < n; j++) {
                num[i][j] = sc.nextInt();
            }
        }
        setZeroes(num);
        //格式化输入
        System.out.print("[");
        for(int i = 0; i < m; i++) {
            System.out.print("[");
            for(int j = 0; j < n; j++) {
                System.out.print(num[i][j]);
                if(j < n-1) {
                    System.out.print(",");
                }
            }
            System.out.print("]");
            if(i < m-1) {
                System.out.print(",");
            }
        }
        System.out.print("]");
    }
}
